package com.itheima.filedemo;

import java.io.File;

public class FileDemo5 {
    public static void main(String[] args) {
//        method1();
//        method2();
//        method3();
        File file = new File("a.txt");
        // 1. 调用者是文件，获取文件名和后缀名
        // 2. 调用者是文件夹，获取文件夹名
        String name = file.getName();
        System.out.println(name);

        File file1 = new File("D:\\IdeaProjects\\JavaStudyProject\\FileModule\\itheima\\");
        String name1 = file1.getName();
        System.out.println(name1);
    }

    private static void method3() {
        File file = new File("a.txt");
        boolean result = file.exists();
        System.out.println(result);
    }

    private static void method2() {
        File file = new File("D:\\IdeaProjects\\JavaStudyProject\\FileModule\\itheima\\");
        boolean result1 = file.isFile();
        boolean result2 = file.isDirectory();
        System.out.println(result1);
        System.out.println(result2);
    }

    private static void method1() {
        File file = new File("D:\\IdeaProjects\\JavaStudyProject\\FileModule\\itheima\\a.txt");
        boolean result1 = file.isFile();
        boolean result2 = file.isDirectory();
        System.out.println(result1);
        System.out.println(result2);
    }
}
